﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BannerLib4Net.Security.Settings
{
    public class AesConfigurationSettings
    {
        public string SaltValue { get; set; }
        public string HashAlgorithm { get; set; }
        public Int32 PasswordIterations { get; set; }
        public string InitVector { get; set; }
        public Int32 KeySize { get; set; }
        public string EncryptionKey { get; set; }
        public String ErrorMessage { get; set; }

        public AesConfigurationSettings()
        {

            this.SaltValue = String.Empty;
            this.HashAlgorithm = String.Empty;
            this.PasswordIterations = Int32.MinValue;
            this.InitVector = String.Empty;
            this.KeySize = Int32.MinValue;
            this.EncryptionKey = String.Empty;

        }

        public bool IsValid
        {
            get
            {

                if (String.IsNullOrEmpty(SaltValue))
                {
                    ErrorMessage = "You must provide a Salt Value in the configuration setting";
                    return false;
                }

                if(String.IsNullOrEmpty(HashAlgorithm))
                {
                    ErrorMessage = "You must provide a Hash Algorithm in the configuration setting";
                    return false;                    
                }

                if(PasswordIterations == Int32.MinValue)
                {
                    ErrorMessage = "You must provide Password Iterations in the configuration setting";
                    return false;                                        
                }

                if (String.IsNullOrEmpty(InitVector))
                {
                    ErrorMessage = "You must provide an Init Vector in the configuration setting";
                    return false;
                }

                if (KeySize == Int32.MinValue)
                {
                    ErrorMessage = "You must provide a Key Size in the configuration setting";
                    return false;
                }

                if (String.IsNullOrEmpty(EncryptionKey))
                {
                    ErrorMessage = "You must provide a Encryption Key in the configuration setting";
                    return false;
                }

                return true;
            }
        }




    }
}
